package com.bw.login.net

import android.util.Log
import androidx.lifecycle.MutableLiveData
import com.bw.common.vm.BaseViewModel
import com.bw.database.db.AppDataBase
import com.bw.database.db.RoomUtils
import com.bw.database.entity.UserInfoEntity
import com.bw.login.entity.UserResult
import com.bw.http.utils.zgr.OkHttpClientManager
import kotlinx.coroutines.*
import java.util.concurrent.Executor
import java.util.concurrent.Executors

class LoginViewModel : BaseViewModel() {





    val loginSuccess by lazy { MutableLiveData<UserResult>() }
    val registerSuccess by lazy { MutableLiveData<UserResult>() }

    private val apiService: ApiService = OkHttpClientManager.retrofitInstance.create(ApiService::class.java)



    fun login(username: String, password: String) {
        executeNetwork(
            { apiService.login(username, password) },
            loginSuccess::postValue
        )
    }

    fun register(username:String,password:String) {
        executeNetwork(
            { apiService.register(username, password) },
            registerSuccess::postValue
        )
    }




}